package com.youdianda.controller;

import com.youdianda.dto.YddAdvposPageDTO;
import com.youdianda.entity.YddAdvpos;
import com.youdianda.result.Result;
import com.youdianda.service.YddAdvposService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("/ydd_advpos")
@RestController
public class YddAdvposController {

    @Autowired
    private YddAdvposService yddAdvposService;
//    分页查询
    @GetMapping("/list")
    public Result list(YddAdvposPageDTO yddAdvposPageDTO){
//        List<YddAdvpos> list = yddAdvposService.list();
        return yddAdvposService.list(yddAdvposPageDTO);
    }
//    数据修改
    @PostMapping("/update")
    public Result update(@RequestBody YddAdvpos yddAdvpos){
     yddAdvposService.update(yddAdvpos);
     return Result.success("ok");
    }
//    数据删除
    @GetMapping("/del")
    public Result del(Integer id){
        yddAdvposService.del(id);
        return Result.success("ok");
    }
//    根据id查询
    @GetMapping("/rowInfo")
    public Result rowInfo(Integer id){
        Result rowInfo = yddAdvposService.rowInfo(id);
        return rowInfo;
    }
    /*POST /ydd_advpos/add*/
    /*广告位添加*/
    @PostMapping("/add")
    public Result add(@RequestBody YddAdvpos yddAdvpos){
        yddAdvposService.save(yddAdvpos);
        return Result.success("ok");
    }
    @GetMapping("/all")
    public Result all(){
        List<YddAdvpos> list = yddAdvposService.list();
        return Result.success(list);
    }

}
